// DlgFileProperty.cpp : implementation file
//

#include "stdafx.h"
#include "ansieditor.h"
#include "DlgFileProperty.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgFileProperty dialog


CDlgFileProperty::CDlgFileProperty(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgFileProperty::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgFileProperty)
	m_nPageHeight = 0;
	m_nPageWidth = 0;
	//}}AFX_DATA_INIT
}


void CDlgFileProperty::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgFileProperty)
	DDX_Control(pDX, IDC_TXT_KEYWORDS, m_txtKeywords);
	DDX_Control(pDX, IDC_TXT_COMMENT, m_txtComment);
	DDX_Text(pDX, IDC_EDIT_HEIGHT, m_nPageHeight);
	DDV_MinMaxInt(pDX, m_nPageHeight, 1, 65535);
	DDX_Text(pDX, IDC_EDIT_WIDTH, m_nPageWidth);
	DDV_MinMaxInt(pDX, m_nPageWidth, 1, 512);
	//}}AFX_DATA_MAP
	DDX_Text(pDX, IDC_TXT_COMMENT, m_sComment);
	DDX_Text(pDX, IDC_TXT_KEYWORDS, m_sKeywords);
	DDX_Text(pDX, IDC_TXT_AUTHOR, m_sAuthor);
}

BEGIN_MESSAGE_MAP(CDlgFileProperty, CDialog)
	//{{AFX_MSG_MAP(CDlgFileProperty)
	ON_BN_CLICKED(IDC_BTN_MORE, OnBtnMore)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgFileProperty message handlers

BOOL CDlgFileProperty::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	//
	CRect rect;
	GetWindowRect(rect);
	m_nInitHeight = rect.Height();

	((CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_WIDTH))->SetRange32(1, 512);
	((CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_HEIGHT))->SetRange32(1, 65535);
	
	GetDlgItemText(IDC_BTN_MORE, m_sBtnMore);
	m_sBtnLess = gpApp->m_mui.LoadString(IDS_BTN_LESS);

	gpApp->m_mui.UpdateDialog(this, IDD);
	return TRUE;
}

void CDlgFileProperty::OnBtnMore() 
{
	CRect rect;
	GetWindowRect(rect);
	BOOL bExpanded = (rect.Height() != m_nInitHeight);
	if(bExpanded)
	{
		rect.bottom -= 168;
		SetDlgItemText(IDC_BTN_MORE, m_sBtnMore);
	}
	else
	{
		rect.bottom += 168;
		SetDlgItemText(IDC_BTN_MORE, m_sBtnLess);
	}
	MoveWindow(rect);
	m_txtKeywords.EnableWindow(!bExpanded);
	m_txtComment.EnableWindow(!bExpanded);
}
